'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
     await queryInterface.createTable('category', { 
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER,
        comment: 'id'
      },
      name: {
        type: Sequelize.STRING,
        allowNull: false,
        defaultValue: '',
        comment: '分类名'
      }, 
      pid: {
        type: Sequelize.INTEGER,
        allowNull: false,
        defaultValue: 0,
        comment: '父分类id'
      },
      created_at: {
        allowNull: false,
        type: Sequelize.DATE,
        filed: 'created_at',
        comment: '创建时间'
      },
      updated_at: {
        allowNull: false,
        type: Sequelize.DATE,
        filed: 'updated_at',
        comment: '更新时间'
      }
    }, {
      tableName: 'category',
      charset: 'utf8mb4',
      collate: 'utf8mb4_bin',
      indexes: [
        {

        }
      ]
    });
  },

  down: async (queryInterface, Sequelize) => {
     await queryInterface.dropTable('category');
  }
};
